package com.yunti.springboot.commonenum;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 审核流程配置
 *
 * @author luojianguo
 */
@Getter
@AllArgsConstructor
public enum SubjectEnum {

    /**
     * 退换审核全局配置编码
     */
    WUSHIMIPAO(1,"WUSHIMIPAO","50米跑",1),
    YIFENZHONGTIAOSHENG(2,"YIFENZHONGTIAOSHENG","1分钟跳绳",2),
    YIQIANMIPAO(3,"YIQIANMIPAO","1000米跑",3),
    BABAIMIPAO(4,"BABAIMIPAO","800米跑",4),

    YINTIXIANGSHANG(5,"YINTIXIANGSHANG","引体向上",5),
    YANGWOQIZUO(6,"YANGWOQIZUO","1分钟仰卧起坐",6),
    ZUOWEITIQIANQU(7,"ZUOWEITIQIANQU","坐位体前屈",7),
    LIANGBAIMIYOUYONG(8,"LIANGBAIMIYOUYONG","200米游泳",8),
    LIDINGTIAOYUAN(9,"LIDINGTIAOYUAN","立定跳远",9),
    SHIXINQIU(10,"WUSHIMIPAO","投掷实心球",10),
    YIBAIMIPAO(11,"YIBAIMIPAO","100米跑",11),

    WANFANPAO(12,"WANFANPAO","15米X4往返跑",12),

    ZUQIU(15,"ZUQIU","足球",13),
    LANQIU(16,"LANQIU","篮球",14),
    PAIQIU(17,"PAIQIU","排球",15),
    PINGPANGQIU(18,"PINGPANGQIU","乒乓球",16),
    YUMAOQIU(19,"YUMAOQIU","羽毛球",17),
    WANGQIU(20,"WUSHIMIPAO","网球",18),
    TAOLU(21,"TAOLU","套路",19),
    SANDA(22,"SANDA","散打",20),
    TICAO(23,"TICAO","体操",21),

    HEIGHT(26,"HEIGHT","身高(厘米)",22),
    WEIGHT(13,"WEIGHT","体重(千克)",23),
    FEIHUOLIANG(14,"FEIHUOLIANG","肺活量(毫升)",24),
    BMI(27,"BMI","体重指数BMI",25),
    LUNGINDEX(28,"LUNGINDEX","肺活量指标",26),
    未知(0,"未知","未知",27);

    /**
     * 编码
     */
    private Integer code;

    /**
     * tuihuanKind编码
     */
    private String key;

    /**
     * 名称
     */
    private String message;


    /**
     * 排序
     */
    private Integer index;


    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * @param subId
     * @return
     */
    public static SubjectEnum getEnumBySubId(Integer subId) {
        SubjectEnum[] value = values();
        for (SubjectEnum e : value) {
            if (e.getCode().equals(subId)) {
                return e;
            }
        }
        return 未知;
    }

    public static SubjectEnum getEnumBySubName(String subName) {
        SubjectEnum[] value = values();
        for (SubjectEnum e : value) {
            if (e.getMessage().equals(subName)) {
                return e;
            }
        }
        return null;
    }

    public static Integer getIndexById(Integer id){
        SubjectEnum[] subItemsEnums = values();
        for (SubjectEnum itemsEnum: subItemsEnums) {
            if(id.equals(itemsEnum.getCode())){
                return itemsEnum.getIndex();
            }
        }
        return 0;
    }

    public static String getNameById(Integer id){
        SubjectEnum[] subItemsEnums = values();
        for (SubjectEnum itemsEnum: subItemsEnums) {
            if(id.equals(itemsEnum.getCode())){
                return itemsEnum.getMessage();
            }
        }
        return "";
    }
    // 是否含有子项目
    public static boolean isHaveSubItems(Integer id){
         return id >= 15 && id <= 23;
    }
}
